#include <iostream>

using namespace std;

int average(int length,int width){
	if (length < width || length <= 0 || width <= 0){
		return -1;
	}
	if (length%width==0) {
		return width;
	}
	int smallWidth = length % width;
	
	cout << smallWidth << endl;
	return average(width,smallWidth);
}


int main(){
	cout << average(1680,640) << endl;
	return 0;	
}
